I currently have a trigger set on object change which validates an attribute change. Depending on the change a warning message may be issued to the user. When changes are made to multiple objects I do not want the warning message to appear for every object. I can determine if a selection is made (getSelection) but generally users apply a filter then change the display set. How can I determine, in the trigger code, if the user is applying a change to multiple objects?
bool StatusAttrTrigger (Trigger trg)
{
if (attrdef (trg) != ATTR_STATUS)
return true
Object o = object (trg)
string actualState = o.ATTR_STATUS
string targetState = value(trg)
string stateChange = actualState "." targetState
if (!find (skpValidStatusTransitions, stateChange))
{
//TODO repeated confirmation if user attempts to change the state of multiple objects!
string asOpts[] = { "Change Status", "Cancel" }
int iSel = query ("This status transition does not comply with the business process model", asOpts)
if (iSel == 1)
return false
}
return true
}
Trigger tPre = trigger (module->formal->all->attribute, modify, 10, StatusAttrTrigger)
--- Martin
Martin_Hunter - Wed May 14 10:40:03 EDT 2014 |
Re: Supress object trigger warning on multiple selection First off that is a pre-attribute-modify trigger, not a pre-object-sync trigger; which you referenced in your first sentance "set on object change". It is also a dynamic trigger and exists only for so long as the module is open. Seems to me you'd prefer a "stored" trigger, but that is another story. Do I understand correctly? If you define A.B as a valid transition but A.C is not, then:
First solution that comes to mind is to figure that a sequence of updates are performed VERY fast, where as it manually it takes over a second to do each. Therefore, perhaps you could forgo a confirmation if the same transition was just performed "recently".
But I think you have another problem. If they say change the value to "B" for all displayed objects, it seems to me you would want to confirm "A.B" transitions once, but also illegal "C.B" transitions once. You can sort of get there by
Digressing even more, since this is a dynamic trigger perhaps if they confirm "A.B" once it could stay confirmed for all future edits of this module during this session. If so, forget what I said above and just put A.B in the skip if they confirm it. So if they confirm A.B, do something else, then try that transition for some other object, it auto happens. -Louie |
Re: Supress object trigger warning on multiple selection llandale - Wed May 14 13:05:17 EDT 2014 First off that is a pre-attribute-modify trigger, not a pre-object-sync trigger; which you referenced in your first sentance "set on object change". It is also a dynamic trigger and exists only for so long as the module is open. Seems to me you'd prefer a "stored" trigger, but that is another story. Do I understand correctly? If you define A.B as a valid transition but A.C is not, then:
First solution that comes to mind is to figure that a sequence of updates are performed VERY fast, where as it manually it takes over a second to do each. Therefore, perhaps you could forgo a confirmation if the same transition was just performed "recently".
But I think you have another problem. If they say change the value to "B" for all displayed objects, it seems to me you would want to confirm "A.B" transitions once, but also illegal "C.B" transitions once. You can sort of get there by
Digressing even more, since this is a dynamic trigger perhaps if they confirm "A.B" once it could stay confirmed for all future edits of this module during this session. If so, forget what I said above and just put A.B in the skip if they confirm it. So if they confirm A.B, do something else, then try that transition for some other object, it auto happens. -Louie Louie, I had come to the same conclusion that the time between changes can be used to determine that a block of objects have been selected. Many thanks - Martin
|